package com.itheima.boject;

import java.util.Scanner;

public class StringReverseDemo {
    public static void main(String[] args) {
        //键盘录入
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入对称字符串");
        String s = sc.nextLine();
        //将键盘录入的字符串反转
        //将字符串封装为StringBuilder对象,目的是为了调用其反转的方法
        StringBuilder sb = new StringBuilder(s);

        sb.reverse();
        //将反转后的内容重新转为String类型
        String reverseStr = sb.toString();
        //s = String
        //sb = StringBuilder
        //将反转后的字符串,和原字符串进行比较
        if (s.equals(reverseStr)){
            System.out.println("是对称字符串");
        }else{
            System.out.println("不是对称字符串");
        }
    }
}
